package com.swk.filter;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;

/**
 * 
 * @author 慎伟康
 * 
 * @date 2017年9月21日 下午4:51:43
 * 
 * @Description TODO
 *		设置请求响应对象编码
 */
@WebFilter("/*")
public class BaseFilter implements Filter {

    public BaseFilter() {
    }

    /**
     * 初始化方法
     */
    public void init(FilterConfig fConfig) throws ServletException {
    	// TODO Auto-generated method stub
    }

	/**
	 * 过滤
	 */
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		String charset = "UTF-8";
		request.setCharacterEncoding(charset);
		response.setCharacterEncoding(charset);
		chain.doFilter(request, response);
	}

	/**
	 * 销毁方法
	 */
	public void destroy() {
	}

}
